package InvestmentPojo;

import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import Notifications.notificationsDataLoading;
import adminLoginPack.FemaUtilAuthenticate;

public class UIFormServiceAction extends Action {

	  public ActionForward execute(ActionMapping mapping, ActionForm inForm, HttpServletRequest request, HttpServletResponse response) throws Exception {

		  Properties props = new Properties(System.getProperties());
		  String method = null;
		  String serviceNo = null;
		  String userId = null;
		  String forwardName = "";
		  
		  try{

			  method = null != request.getParameter("methodName")?request.getParameter("methodName"):"";
			  String showServicemethod = null != request.getParameter("showServicePage")?request.getParameter("showServicePage"):"";
			  serviceNo = null != request.getParameter("serviceIdForservice")?request.getParameter("serviceIdForservice"):"";
			  userId = null != request.getParameter("UserIDForservice")?request.getParameter("UserIDForservice"):"";
			  
			  if(!"".equals(userId)){
				  userId =  null !=  request.getSession().getAttribute("UserID")?(String) request.getSession().getAttribute("UserID"):""; 
			  }
			  FemaUtilAuthenticate femaUtil = new FemaUtilAuthenticate();
			  
			  boolean isUserExist = femaUtil.isUserExist(request, response,userId);
			  if(!isUserExist){
				  forwardName =  "authfailed";
			  }
		  notificationsDataLoading ndb = new notificationsDataLoading();
		 
		  if(null != method){
			  if(method.equals("showService")){
				 
				  int service = Integer.parseInt(serviceNo);
				  String defaultPage = "/ServiceShowPages/defaultServiceShowPage"+service+".html";
				  switch(service){
				  case 1:
					  request.setAttribute("showServiceName", "TOOLS");
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("UserID",userId);
					  request.setAttribute("defaultShowServicePage", defaultPage);
					  request.setAttribute("TOOLName", "FOREIGN DIRECT INVESTMENT");
					  break;
				  case 2 :
					  request.setAttribute("showServiceName", "TOOLS");
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("defaultShowServicePage", defaultPage);
					  request.setAttribute("UserID",userId);
					  request.setAttribute("TOOLName", "IMMOVABLE PROPERTY IN INDIA");
					  break;
				  case 3 :
					  request.setAttribute("showServiceName", "TOOLS");
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("defaultShowServicePage", defaultPage);
					  request.setAttribute("UserID",userId);
					  request.setAttribute("TOOLName", "BRANCH/LIAISON OFFICE/PROJECT OFFICE IN INDIA");
					  break;
				  case 4 :
					  request.setAttribute("showServiceName", "TOOLS");
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("defaultShowServicePage", defaultPage);
					  request.setAttribute("UserID",userId);
					  request.setAttribute("TOOLName", "BORROWING IN RUPEES");
					  break;
				  case 5 :
					  request.setAttribute("showServiceName", "EXTERNAL COMMERCIAL BORROWING");
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("defaultShowServicePage", defaultPage);
					  request.setAttribute("UserID",userId);
					  request.setAttribute("TOOLName", "EXTERNAL COMMERCIAL BORROWING");
					  break;
				  case 6 :
					  request.setAttribute("showServiceName", "EXPORTS OF GOODS & SERVICES");
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("defaultShowServicePage", defaultPage);
					  request.setAttribute("UserID",userId);
					  request.setAttribute("TOOLName", "EXPORT OF GOODS & SERVICES");
					  break;
				  case 7 :
					  request.setAttribute("showServiceName", "TOOLS");
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("defaultShowServicePage", defaultPage);
					  request.setAttribute("UserID",userId);
					  request.setAttribute("TOOLName", "OVERSEAS DIRECT INVESTMENT");
					  break;
				  case 8 :
					  request.setAttribute("showServiceName", "TOOLS");
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("defaultShowServicePage", defaultPage);
					  request.setAttribute("UserID",userId);
					  request.setAttribute("TOOLName", "IMMOVABLE PROPERTY ABROAD");
					  break;
				  case 9 :
					  request.setAttribute("showServiceName", "BRANCH OFFICE OUTSIDE INDIA");
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("defaultShowServicePage", defaultPage);
					  request.setAttribute("UserID",userId);
					  request.setAttribute("TOOLName", "BRANCH OFFICE OUTSIDE INDIA");
					  break;
				  case 10 :
					  request.setAttribute("showServiceName", "IMPORT OF GOODS AND SERVICES");
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("defaultShowServicePage", defaultPage);
					  request.setAttribute("UserID",userId);
					  request.setAttribute("TOOLName", "IMPORT OF GOODS AND SERVICES");
					  break;
				  case 11 :
					  request.setAttribute("showServiceName", "FOREIGN EXCHANGE REMITTANCES");
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("defaultShowServicePage", defaultPage);
					  request.setAttribute("UserID",userId);
					  request.setAttribute("TOOLName", "FOREIGN EXCHANGE REMITTANCES");
					  break;
				  case 12 :
					  request.setAttribute("showServiceName", "TOOLS");
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("defaultShowServicePage", defaultPage);
					  request.setAttribute("UserID",userId);
					  request.setAttribute("TOOLName", "FOREIGN EXCHANGE REMITTANCES");
					  break;
				  case 13 :
					  request.setAttribute("showServiceName", "FORMS & FORMATS");
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("defaultShowServicePage", "FormsNFormats.jsp");
					  request.setAttribute("UserID",userId);
					  request.setAttribute("TOOLName", "FORMS & FORMATS");
					  break;
				  case 14 :
					  request.setAttribute("showServiceName", "COMPOUNDING OF OFFENCES");
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("defaultShowServicePage", defaultPage);
					  request.setAttribute("UserID",userId);
					  request.setAttribute("TOOLName", "COMPOUNDING OF OFFENCES");
					  break;
				  case 15 :
					  request.setAttribute("showServiceName", "GOVT APPROVALS");
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("defaultShowServicePage", defaultPage);
					  request.setAttribute("UserID",userId);
					  request.setAttribute("TOOLName", "GOVT APPROVALS");
					  break;
				  case 16 :
					  request.setAttribute("showServiceName", "Service 4");
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("defaultShowServicePage", defaultPage);
					  request.setAttribute("UserID",userId);
					  request.setAttribute("TOOLName", "");
					  break;
				  case 17 :
					  request.setAttribute("showServiceName", "Service 5");
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("defaultShowServicePage", defaultPage);
					  request.setAttribute("UserID",userId);
					  request.setAttribute("TOOLName", "");
					  break;
				  case 18 :
					  request.setAttribute("showServiceName", "Service 6");
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("defaultShowServicePage", defaultPage);
					  request.setAttribute("UserID",userId);
					  request.setAttribute("TOOLName", "");
					  break;
				 default :
					  request.setAttribute("UserIDForservice", serviceNo);
					  request.setAttribute("UserID",userId);
					  break;
				  }
				  if(serviceNo.equals("1")){
					  
				  }
				  forwardName = "applicationform";
			  }
			  
		  }
		  String str = "";
		  }catch(Exception e) {
			  e.printStackTrace();
		  }
		  return mapping.findForward(forwardName); // Not forwarding to anywhere, response is fully-cooked
	  }

}
